package com.xyf.blog.service;

import com.xyf.blog.dao.UserRepository;
import com.xyf.blog.po.Type;
import com.xyf.blog.po.User;
import com.xyf.blog.util.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

//    注入接口，交给springboot创建对象
    @Autowired
    private UserRepository userRepository;


    @Override
    public User checkUser(String username, String password) {

        User user=userRepository.findByUsernameAndPassword(username, MD5Utils.code(password));
        return user;
    }

    /**
     * 添加新的管理员
     * @param user
     * @return
     */
    @Override
    public User saveUser(User user){
        User user1=userRepository.save(user);
        return user1;
    }


}
